package com.rpc.example.constant;

/**
 * @author Elvis
 * @version 1.0, 2022/11/9
 */
public enum RequestTypeEnum {
    /**
     *
     */
    REQUEST((byte) 1),
    RESPONSE((byte) 2),
    HEARBEAT((byte) 3),
    ;

    RequestTypeEnum(byte code) {
        this.code = code;
    }

    private final byte code;

    public byte getCode() {
        return this.code;
    }

    public static RequestTypeEnum findByCode(byte code) {
        for (RequestTypeEnum value : RequestTypeEnum.values()) {
            if (value.getCode() == code) {
                return value;
            }
        }
        throw new IllegalArgumentException("illegal request type code: " + code);
    }


}
